#!/usr/bin/env python3
# coding: UTF-8
# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

import unittest

from mx_rec.util.config_utils.hybrid_mgmt_utils import HybridManagerConfig


class TestHybridManagerConfig(unittest.TestCase):
    def test_init_ok(self):
        hybrid_manager_config = HybridManagerConfig()
        self.assertIsNone(hybrid_manager_config.asc_manager)
        self.assertFalse(hybrid_manager_config.freeze)

    def test_trigger_evict_err(self):
        hybrid_manager_config = HybridManagerConfig()
        with self.assertRaises(RuntimeError):
            hybrid_manager_config.trigger_evict()

    def test_get_host_data_err(self):
        hybrid_manager_config = HybridManagerConfig()
        with self.assertRaises(RuntimeError):
            hybrid_manager_config.get_host_data(table_name="xxx")

    def test_get_load_offset_err(self):
        hybrid_manager_config = HybridManagerConfig()
        with self.assertRaises(RuntimeError):
            hybrid_manager_config.get_load_offset(table_name="xxx")

    def test_set_optim_info_err(self):
        hybrid_manager_config = HybridManagerConfig()
        with self.assertRaises(RuntimeError):
            hybrid_manager_config.set_optim_info(table_name="xxx", optim_info="x")

    def test_save_host_data_err(self):
        hybrid_manager_config = HybridManagerConfig()
        with self.assertRaises(RuntimeError):
            hybrid_manager_config.save_host_data(root_dir="xxx", save_delta=True, is_save_l3_storage=False)

    def test_restore_host_data_err(self):
        hybrid_manager_config = HybridManagerConfig()
        with self.assertRaises(RuntimeError):
            hybrid_manager_config.restore_host_data(root_dir="xxx")

    def test_fetch_device_emb_err(self):
        hybrid_manager_config = HybridManagerConfig()
        with self.assertRaises(RuntimeError):
            hybrid_manager_config.fetch_device_emb()

    def test_start_sync_thread_err(self):
        hybrid_manager_config = HybridManagerConfig()
        with self.assertRaises(RuntimeError):
            hybrid_manager_config.start_sync_thread()
